﻿using System;
using System.Threading;
using System.Threading.Tasks;
using name.heby.Async;

namespace name.heby
{
    public class AsyncTest2
    {
        public static void Test()
        {
            ASyncTest();
            Console.WriteLine($"Main : {Thread.CurrentThread.ManagedThreadId}");
        }

        public static async void ASyncTest()
        {
            Console.WriteLine($"ASyncTest ManagedThreadId : {Thread.CurrentThread.ManagedThreadId}");
            for (int i = 0; i < 1; i++)
            {
                await TestTask();
            }

            Console.WriteLine($"ASyncTest ManagedThreadId : {Thread.CurrentThread.ManagedThreadId}");
        }

        public static async Task<int> TestTask()
        {
            await Task.Delay(1000);
            Console.WriteLine($"Task, Thread ID1 : {Thread.CurrentThread.ManagedThreadId}");
            await Task.Delay(1000);
            Console.WriteLine($"Task, Thread ID2 : {Thread.CurrentThread.ManagedThreadId}");
            return 1;
        }
    }
}